package com.smartkey.activity;

import com.project.smartkey.R;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;

public class HeadsetPluSelectorActivity extends BaseActivity {

	public static final String ACTION_MSG = "com.smartkey.headsetplugmsg";
	HeadSetPlugMessageReceiver headSetPlugMessageReceiver;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sk_activity_headsetplug);
		registerBroadcastReceiver();
	}

	@Override
	public void finish() {
		super.finish();
		unregisterReceiver(headSetPlugMessageReceiver);
	}

	private void registerBroadcastReceiver() {
		headSetPlugMessageReceiver = new HeadSetPlugMessageReceiver();
		IntentFilter intentFilter = new IntentFilter();
		intentFilter.addAction(ACTION_MSG);
		registerReceiver(headSetPlugMessageReceiver, intentFilter);
	}

	private class HeadSetPlugMessageReceiver extends BroadcastReceiver {

		@Override
		public void onReceive(Context context, Intent intent) {
			finish();
		}

	}
}
